<!DOCTYPE html>
<html>
	<head>
		<meta name="viewport" content="initial-scale=1, maximum-scale=1">

		<title>
			新引擎测试页面
		</title>
		<meta charset = "utf-8">
		<script type="text/javascript">
		   //获取已安装模块列表
			function getInstalledModuleList() {
				try{
					navigator.moduleoperation.getInstalledModuleList(function(list) {
						alert(list);
					},function(err) {
						alert(err);
					});
				}catch(e){alert(e)}
			}
			//获取未安装模块列表
			function getUnInstalledModuleList() {
				try{
				navigator.moduleoperation.getUninstallModuleList(function(list) {
					alert(list);
				},function(err) {
					alert(err);
				});
				}catch(e){alert(e)}
			}

			//获取待更新模块列表
			function getUpgradeableModuleList() {
				try{
				navigator.moduleoperation.getUpgradeableModuleList(function(list) {
					alert(list);
				},function(err) {
					alert(err);
				});
				}catch(e){alert(e)}
			}

			function getAllModuleList() {
				try {
					navigator.moduleoperation.getAllModuleList(function(list) {
						alert(list);
						document.getElementById('info').innerHTML=list
					},function(err) {
						alert(err);
					});
				} catch (e) { alert(e) }
			}

			//安装模块
			function installModule(identify) {
				var identify = document.getElementById('moduleID').value;
				console.log('identify->%s',identify)
				if(!identify) return alert('empty')
				try {
				navigator.moduleoperation.installModule(function(a) {
					alert(a)
				},function(err) {
					alert(err);
				},identify);
				}catch(e){alert(e)}
			}

			//升级模块
			function upgradeModule(identify) {
				var identify = document.getElementById('moduleID').value;
				console.log('identify->%s',identify)
				if(!identify) return alert('empty')
				try {
				navigator.moduleoperation.upgradeModule(function(a) {
					alert(a)
				},function(err) {
					alert(err);
				},identify);
				}catch(e){alert(e)}
			}

			//删除模块
			function deleteModule(identify) {
				var identify = document.getElementById('moduleID').value;
				console.log('identify->%s',identify)
				if(!identify) return alert('empty')
				try {
					navigator.moduleoperation.deleteModule(function(a) {
						alert(a)
					},function(err) {
						alert(err);

					},identify);
				}catch(e){alert(e)}
			}

			function test() {
				navigator.moduleoperation.test(function() {

				},function(err) {

				},"com.test.module");
			}

			function moduleDownloadStart(identify) {
				// alert('moduleDownloadStart====>' + identify );
				document.getElementById('downloadinfo').innerHTML = 'moduleDownloadStart====>' + identify
			}

			function updateModuleProgress(identify,progress) {
				// alert('updateModuleProgress====>' + identify + 'progress===>' + progress );
				document.getElementById('downloadinfo2').innerHTML = 'updateModuleProgress====>' + identify + '<br/>progress===>' + progress
			}
		</script>
	</head>
	<body>
		<h1>navigator方式接口测试</h1>
		<button id= 'getAllModuleList' onclick="getAllModuleList();">获取所有模块列表</button><br><br><br>
		<button id= 'getInstalledModuleList' onclick="getInstalledModuleList();">获取安装模块列表</button><br><br><br>
		<button id= 'getUnInstalledModuleList' onclick="getUnInstalledModuleList();">获取未安装模块列表</button><br><br><br>
		<button id= 'getUpgradeModuleList' onclick="getUpgradeableModuleList();">获取更新模块列表</button><br><br><br>
		<div id="info" style=" background-color: #ccc; min-height: 1em;"></div><br><br>
		<div id="downloadinfo" style=" background-color: #ccc; min-height: 1em;"></div><br><br>
		<div id="downloadinfo2" style=" background-color: #ccc; min-height: 1em;"></div><br><br>
		<br><br><input type="text" name="name" value="" id="moduleID"><br><br><br>
		<button id= 'installModule' onclick="installModule();">安装模块</button><br><br><br>
		<button id= 'upgradeModule' onclick="upgradeModule();">升级模块</button><br><br><br>
		<button id= 'deleteModule' onclick="deleteModule();">删除模块</button><br><br><br>
		<!-- <button id= 'checkAppUpdate'>检测App</button><br> -->
		<!-- <button id= 'test' onclick="test();">测试</button><br> -->
		<button style="width:150px;height:100px;text-align:center;background-color: #ccc;font-size: 3em;" onclick="history.back();">返回</button>
	</body>
	<script type="text/javascript" src="../../cordova.js"></script>
</html>
